#include "choice.h"
#include "ui_choice.h"
#include<QDebug>
#include<QPushButton>
#include<QLabel>
Choice::Choice(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::Choice)
{
    ui->setupUi(this);//每次点击按钮都触发信号
    QTimer *timer1=new QTimer(this);//timer1每次必须重建，不可以是成员函数
    connect(this->ui->pushButton,&QPushButton::clicked,[&](){
        qDebug()<<"1 is cliked";
        this->buttonclick1();
    });
    connect(this->ui->pushButton_2,&QPushButton::clicked,[&](){this->buttonclick2(),buttonclickd();});
    connect(this->ui->pushButton_3,&QPushButton::clicked,[&](){this->buttonclick3(),buttonclickd();});
    connect(this->ui->pushButton_4,&QPushButton::clicked,[&](){this->buttonclick4(),buttonclickd();});
    connect(this->ui->pushButton_5,&QPushButton::clicked,[&](){this->buttonclick5(),buttonclickd();});
    connect(this->ui->pushButton_6,&QPushButton::clicked,[&](){this->buttonclick6(),buttonclickd();});
    connect(this->ui->pushButton_7,&QPushButton::clicked,[&](){this->buttonclick7(),buttonclickd();});
    connect(this->ui->pushButton_8,&QPushButton::clicked,[&](){this->buttonclick8(),buttonclickd();});
    connect(this->ui->pushButton_9,&QPushButton::clicked,[&](){this->buttonclick9(),buttonclickd();});
    connect(this->ui->pushButton_11,&QPushButton::clicked,[&](){this->buttonCancel();});
    connect(this->ui->pushButton_12,&QPushButton::clicked,[&](){this->buttonReDo();});
    connect(this->ui->pushButton_13,&QPushButton::clicked,[&](){this->ShowAnswerButton();});
    connect(this,&Choice::showNotRight,[&](){
        //this->timer=new QTimer();不需要初始化

        qDebug()<<"this->ui->pushButton_11->setText("");";
        timer1->start(2000);
        this->ui->pushButton_11->setText("走法无效");
    });
    connect(timer1,&QTimer::timeout,[&](){
        this->ui->pushButton_11->setText("撤销");
        timer1->stop();
    });
}
//int Choice::isclosed=0;//静态变量必须头文件类内定义，cpp文件类外初始化
Choice::~Choice()
{
    delete ui;
}
void Choice::closeEvent(QCloseEvent *event)
{
   // QMessageBox::StandardButton button;
    this->hide();
    event->ignore();
}

